package com.nku.mason.scm.plugins;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class SysParam
 */
//@WebServlet(name="SysParam", urlPatterns="/sysParam", loadOnStartup=2) 
public class SysParam1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SysParam1() {
        super();
    }
    
	@Override
	public void init() throws ServletException {
		//创建数据字典Map
        Map<String , String> supTypeMap = new HashMap<>();
        Map<String, String> goodsColorMap = new HashMap<>();
        supTypeMap.put("1", "一级供应商");
        supTypeMap.put("2", "二级供应商");
        supTypeMap.put("3", "三级供应商");
        goodsColorMap.put("1","红");
        goodsColorMap.put("2", "绿");
        goodsColorMap.put("3", "蓝");
        
        //创建放入ServletContext的map
        Map<String, Object> sysParam = new HashMap<>();
        sysParam.put("supType" , supTypeMap);
        sysParam.put("goodsColor", goodsColorMap);
        
        //将sysParam放入ServletContext
        this.getServletContext().setAttribute("sysParam", sysParam);
        System.out.println("--------------------系统参数加载完成--------------------");
    }
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
